package zozopo.business.ad;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import zozopo.operations.business.StoreOS;
import zozopo.operations.business.ad.GoodsOS;
import zozopo.user.operations.UserOS;
import zozopo.user.operations.UserTB;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class DeleteGoodsAction extends ActionSupport implements Action,SessionAware{

private Map<Object, Object> session;
	
	private int id;
	
	public void setSession(Map arg0) {
		// TODO Auto-generated method stub
		session = arg0;
	}
	
	public String execute(){
		
		UserTB user = (UserTB) session.get("userInfo"); 
		
		if(user == null){
			//addFieldError("errormessage", "用户未登陆请保存需要发布数据.登陆后再重新发布");
			return NONE;
		}
		
		if(!UserOS.userFlagLeve(user, 33, 1)){
			return NONE;
		}
		
		GoodsOS goodsOS = new GoodsOS();
		
		if(goodsOS.deleteGoodsById(id)){
			goodsOS.releaseConnection();
			return SUCCESS;
		}else{
			goodsOS.releaseConnection();
			return ERROR;
		}	
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}
}
